It is sometimes desirable to add postprocessing logic to a JAVA method after that method is compiled—for example, to insert “probe” logic that will track the method's execution state and return value.
Some existing solutions to this problem involve wrapping the existing method inside a new method. The outer “wrapper” method performs postprocessing steps after the “wrapped” method exits. See the IBM project called HyperProbe for an example of this.
However, such an approach sacrifices execution-path fidelity. Debugging and tracing tools will see the newly-created “wrapper” methods, which can pollute the data and confuse the user. Also, adding wrappers makes the class larger, potentially doubling the number of methods in the class. JAVA class files impose various limits, thus it might not be possible to add a new method without violating one of those limits. An example of a limit is “65536 entries in the constant pool.”